window.onload = function () {

    // 获取节点对象
    let dv = document.getElementById("app")
    // 获取节点对象中的文本内容
    let info = dv.innerText
    console.log(info)

    info = dv.innerHTML
    console.log(info)

    // 改变节点对象中的内容
    dv.innerText = "hello javascript"
    dv.innerHTML = "<span>hello javascript</span>"


    //操作节点对象 css
    dv.style.color = 'red'
    dv.style.fontSize='50px'

    // button 绑定单击事件   返回的伪数组
    let btn = document.getElementsByClassName("btn")
    console.log(btn)
    btn[0].onclick = function (){
        console.log("hello")
    }


    //  动态渲染表格数据  ajax  ->  json
    let students = [
        {
            studentName:'tom1',
            studentNo:"20241207001",
            age:20
        },
        {
            studentName:'tom2',
            studentNo:"20241207002",
            age:30
        }
    ]

    // 遍历学生信息数组  创建节点     对象-> tr  对象属性-> td
    let tbd = document.getElementById("table_data")
    students.forEach(student=>{
        // 创建tr节点对象
        let tr = document.createElement("tr");
        for (let key in student) {
            let td = document.createElement("td");
            td.innerText = student[key]
            tr.append(td)
        }
        tbd.append(tr)
    })











}
